<template>
  <div class="box">
		<h3>企业ID：{{comDetail.companyId}}</h3>
		<p>企业名称：{{comDetail.name}}</p>
		<p>企业地址：{{comDetail.address}}</p>
		<p>公司性质：{{comDetail.propertyValue}}</p>
		<p>公司类型：{{comDetail.typeValue}}</p>
		<p>是否上市：{{comDetail.ipo ? '是' : '否'}}</p>
		<p>联系电话：{{comDetail.mobile}}</p>
		<p v-show="comDetail.saleMobile">销售电话：{{comDetail.saleMobile}}</p>
		<p v-show="comDetail.capital">注册资本：{{comDetail.capital}}</p>
		<p v-show="comDetail.license">营业执照：</p>
		<div>
			<img width="200px" :src="src" alt="" v-for="(src, index) in comDetail.license.split(',')" v-bind:key="index">
		</div>
		<p>公司简介：{{comDetail.intro}}</p>
		<p>修改人：{{comDetail.operatorName}}</p>
		<p>修改原因：{{comDetail.reason}}</p>
		<!-- <p>相关附件：</p> -->
		<div>
			<el-button type="success" class="btn" @click="done(true)">同意</el-button>
			<el-button type="warning" plain class="btn" @click="done(false)">拒绝</el-button>
		</div>
  </div>
</template>

<script>
const queryString = require('querystring')
import { propertyList, typeList } from 'data/listBody'
export default {
	name: 'comInfo',
	data() {
		return {
			comDetail:{
				license: ''
			},
			id: ''
		}
	},
	created() {
		this.getDetail()
	},
	methods: {
		getDetail() {
			this.id = this.$route.query.id
			this.axios.get(`/company/${this.id}/detail`).then((res) => {
              const code = Number(res.data.code)
              if (code === 200) {
									this.comDetail = res.data.data.modified
									this.comDetail.operatorName = res.data.data.operatorName
									this.comDetail.license = this.comDetail.license || ''
									if(this.comDetail.property) this.comDetail.propertyValue = this.key2Value(propertyList, this.comDetail.property)
									if(this.comDetail.type) this.comDetail.typeValue = this.key2Value(typeList, this.comDetail.type)
              } else {
                  this.$message(this.mes.busy)
              }
            }).catch((err) => {
              console.log(err)
              this.$message(this.mes.busy)
            })
		},
		done(status) {
			const params = {
				id: this.id,
				confirm: status
			}
			this.axios.post(`/company/${this.id}/detail/confirm` , queryString.stringify(params)).then((res) => {
							const code = Number(res.data.code)
              if (code === 200) {
									this.$message(this.mes.success)
									this.$router.push('infoRecheck?activeName=1')
              } else {
                  this.$message(this.mes.busy)
							}
            }).catch((err) => {
              console.log(err)
              this.$message(this.mes.busy)
            })
		}
	}
}
</script>

<style lang="less" scoped>
.box{
	padding-left: 50px
}
 .btn{
    margin-left: 20px;
  }
</style>
